import java.util.Scanner;

/**
 * Created by IntelliJ IDEA.
 * User: zm
 * Date: 2023/5/1
 */
public class Demo20 {
    static int N = 1010;
    static int n,m,q;
    static int[][] a = new int[N][N];
    static int[][] b = new int[N][N];

   static  void insert(int x1, int y1, int x2, int y2, int c){
        b[x1][y1] += c;
        b[x2 + 1][y1] -= c;
        b[x1][y2 + 1] -= c;
        b[x2 + 1][y2 + 1] += c;
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt(),m = scan.nextInt(),q = scan.nextInt();
        for(int i = 1; i <= n; i++)
            for(int j = 1; j <= m; j++)
                a[i][j] = scan.nextInt();
        for(int i = 1; i <= n; i++)
            for(int j = 1; j <= m; j++)
                insert(i,j,i,j,a[i][j]);
        while(true){
            if(q-- == 0)break;

            int x1 = scan.nextInt(),y1 = scan.nextInt(),x2 = scan.nextInt(),y2 =scan.nextInt();
            int c = scan.nextInt();

            insert(x1,y1,x2,y2,c);

        }
        for(int i = 1; i <= n; i++)
            for(int j = 1; j <= m; j++)
                b[i][j] += b[i - 1][j] + b[i][j - 1] - b[i - 1][j - 1];
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= m; j++){
                System.out.print(b[i][j] + " ");
            }
            System.out.println();
        }


   }



//    static int N = 100010;
//    static int n,m;
//    static int[] a = new int[N];
//    static int[] b = new int[N];
//    static void insert(int l, int r, int c){
//        b[l] +=c;
//        b[r + 1] -= c;
//    }
//    public static void main(String[] args) {
//        Scanner scan = new Scanner(System.in);
//        int n = scan.nextInt(),m = scan.nextInt();
//        for(int i = 1; i <=  n; i++)a[i] = scan.nextInt();
//
//        for(int i = 1; i <= n; i++)insert(i,i,a[i]);
//
//        while(true) {
//            if (m-- == 0) break;
//            int l = scan.nextInt(), r = scan.nextInt(), c = scan.nextInt();
//            insert(l, r, c);
//        }
//            for(int i = 1; i <= n; i++)b[i] += b[i - 1];
//
//            for(int i = 1; i <= n; i++) System.out.print(b[i] + " ");
//    }
}
